<template>
  <!-- 订单管理 -->
  <div class="app-container">
    <!-- 查询模块 -->
    <div class="formDiv">
      <el-form ref="form" :inline="true" :model="form" label-width="130px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="订单号">
              <el-input v-model="form.order_sn" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="姓名/手机号">
              <el-input v-model="form.username" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="订单状态">
              <el-select v-model="form.order_status" placeholder="请选择" clearable>
                <el-option
                  v-for="(item,index) in statusType"
                  :key="index"
                  :label="item.name"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="订单下单时间" width="236">
              <el-date-picker
                v-model="created_at"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="daterange"
                range-separator="-"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                :default-time="['00:00:00', '23:59:59']"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="订单支付时间" width="236">
              <el-date-picker
                v-model="pay_time"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="daterange"
                range-separator="-"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                :default-time="['00:00:00', '23:59:59']"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="上级姓名/手机号">
              <el-input v-model="form.referee" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6" :offset="18">
            <el-form-item>
              <el-button type="primary" @click="handleSearch">查询</el-button>
              <!-- <el-button type="primary" @click="handleExport">导出</el-button> -->
              <Exprotcomponent :params="form" url="admin/order/card_ticket_export" type="php"></Exprotcomponent>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <!-- 主页列表 -->
    <div class="listDiv" v-loading="tableLoading">
      <el-table ref="tableData" :data="tableData" style="width: 100%" height="500px">
        <!--   -->
        <el-table-column
          fixed
          type="index"
          label="编号"
          width="50"
          align="center"
          :index="table_index"
        />
        <el-table-column label="订单编号" prop="order_sn" align="center" width="200px" />
        <el-table-column label="姓名" prop="buy_user.realname" align="center">
          <template slot-scope="scope">
            <span
              v-if="scope.row.buy_user"
            >{{scope.row.buy_user.realname||scope.row.buy_user.nickname}}</span>
          </template>
        </el-table-column>
        <el-table-column label="手机号" prop="buy_user.username" align="center" width="120px">
          <template slot-scope="scope">
            <span v-if="scope.row.buy_user">{{scope.row.buy_user.username|phonereg}}</span>
          </template>
        </el-table-column>
        <el-table-column label="上级姓名" prop="uid.realname" align="center" width="120px">
          <template slot-scope="scope">
            <span v-if="scope.row.uid">{{scope.row.uid.realname}}</span>
          </template>
        </el-table-column>
        <el-table-column label="上级手机号" prop="uid.username" align="center" width="120px">
          <template slot-scope="scope">
            <span v-if="scope.row.uid">{{scope.row.uid.username|phonereg}}</span>
          </template>
        </el-table-column>
        <el-table-column label="购买卡项" prop="order_item.goods_name" align="center" width="120px" />
        <el-table-column label="订单状态" prop="order_status" align="center" width="120px">
          <template slot-scope="scope">
            <div>{{scope.row.order_status | statusFn}}</div>
            <el-tooltip
              v-if="scope.row.order_status==6||scope.row.order_status==13"
              class="item"
              effect="dark"
              :content="scope.row.get_refund?scope.row.get_refund.return_reason+'':'无'"
              placement="bottom-end"
            >
              <div style="color:red">退款原因</div>
            </el-tooltip>
          </template>
        </el-table-column>
        <!-- 1：全现金 2：全金银币 3：现金+金银币', -->
        <el-table-column label="支付方式" prop="pay_type" align="center" width="120px">
          <template slot-scope="scope">
            <span v-if="scope.row.pay_type==0">无</span>
            <span v-if="scope.row.pay_type==1">全现金</span>
            <span v-if="scope.row.pay_type==2">全金银币</span>
            <span v-if="scope.row.pay_type==3">现金+金银币</span>
          </template>
        </el-table-column>
        <el-table-column label="原价" prop="order_all_price" align="center" width="120px" />
        <el-table-column label="优惠券优惠" prop="ticket_money" align="center" width="120px" />
        <el-table-column label="兑换码优惠" prop="serial_number_money" align="center" width="120px" />
        <el-table-column label="金币抵扣" prop="gold_credit" align="center" width="120px" />
        <el-table-column label="银币抵扣" prop="silver_credit" align="center" width="120px" />
        <el-table-column label="线上支付金额" prop="order_price" align="center" width="140px" />
        <el-table-column label="剩余尾款支付金额" prop="final_money" align="center" width="140px" />
        <el-table-column label="支付时间" prop="pay_time" align="center" width="200px">
          <template slot-scope="scope">
            <span v-if="scope.row.pay_time">{{(scope.row.pay_time-0)*1000| date(1)}}</span>
            <!-- <span v-else></span> -->
          </template>
        </el-table-column>

        <el-table-column label="尾款支付时间" prop="final_time" align="center" width="200px">
          <template slot-scope="scope">
            <span v-if="scope.row.final_time">{{(scope.row.final_time-0)*1000| date(1)}}</span>
            <!-- <span v-else></span> -->
          </template>
        </el-table-column>
        <el-table-column label="退款时间" prop="final_time" align="center" width="200px">
          <template slot-scope="scope">
            <span
              v-if="scope.row.get_refund&&scope.row.get_refund.return_time"
            >{{(scope.row.get_refund.return_time-0)*1000| date(1)}}</span>
          </template>
        </el-table-column>
        <el-table-column label="退款说明" prop="order_price" align="center" width="140px">
          <template slot-scope="scope">
            <span v-if="scope.row.get_refund">{{scope.row.get_refund.return_remark}}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" fixed="right" align="center">
          <template slot-scope="scope">
            <!-- {{scope.row.get_refund}} -->
            <el-button
              v-if="scope.row.order_status==6||scope.row.order_status==13"
              size="small"
              type="text"
              @click="paymentCom(scope.row.id,scope.row.get_refund,scope.row.buy_user.realname,scope.row.buy_user.username,scope.row.order_item.goods_name)"
            >退款</el-button>
            <el-button
              v-if="scope.row.order_status==6||scope.row.order_status==13"
              size="small"
              type="text"
              @click="RefuseRefund(scope.row.id,scope.row.get_refund,scope.row.buy_user.realname,scope.row.buy_user.username,scope.row.order_item.goods_name)"
            >拒绝退款</el-button>
            <el-button size="small" type="text" @click="dividedEtails(scope.row.id,scope.row)">分成详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <div class="pagesCon">
        <div>
          <el-pagination
            :current-page="form.page"
            :page-sizes="page_sizes"
            :page-size="form.pagesize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="page_totals"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </div>
    <!-- 分成详情 -->
    <!-- <el-dialog
      title="分成详情"
      :visible.sync="dialogFormVisible"
      v-loading="infoLoading"
      width="90%"
      center
      class="dialogColor"
      @close="close"
    >
      <div class="content">
        <h5 class="titleInfo">分成详情</h5>
        <el-row>
          <el-col :span="16" style="background:white">
            <el-form
              ref="form1"
              :inline="true"
              label-position="top"
              :model="form1"
              label-width="150px"
            >
              <el-row>
                <el-col :span="8">
                  <el-form-item label="订单编号">
                    <span class="spanToInput">{{form1.detailInfo.order_sn | noFn}}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="购买人姓名">
                    <span class="spanToInput">
                      <span
                        v-if="form1.detailInfo.buy_user"
                      >{{form1.detailInfo.buy_user.realname | noFn}}</span>
                    </span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="手机号">
                    <span class="spanToInput">
                      <span
                        v-if="form1.detailInfo.buy_user"
                      >{{form1.detailInfo.buy_user.referee | noFn}}</span>
                    </span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="购买数量">
                    <span class="spanToInput">{{form1.detailInfo.number | noFn}}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="实付金额">
                    <span class="spanToInput">{{form1.detailInfo.order_price | noFn}}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="订单生成时间">
                    <span class="spanToInput">{{(form1.detailInfo.created_at-0)*1000 | date(1)}}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="分成发放时间">
                    <span class="spanToInput">{{form1.applyTime | noFn}}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="订单状态">
                    <span class="spanToInput">{{form1.detailInfo.order_status | statusFn}}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="分成模式">
                    <span class="spanToInput">{{form1.formTypeValue | noFn}}</span>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
            <div class="line"></div>
            <h5 class="titleInfo">业绩奖励</h5>
            <el-form ref="form1" :inline="true" :model="form1" label-width="150px">
              <div v-if="form1.list1.length>0">
                <el-row v-for="(item,index) in form1.list1" :key="index">
                  <el-col :span="12">
                    <el-form-item
                      :label="item.awardType==16?'会员奖励':item.awardType==1?'一级人员':item.awardType==2?'二级人员':''"
                    >
                      <span class="spanToInput">{{item.realName}}{{item.username}}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="人员级别">
                      <span class="spanToInput">{{item.roleName}}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="奖励比例(%)">
                      <span class="spanToInput">{{item.rewardRate | nullFn}}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="奖励金额">
                      <span class="spanToInput">{{item.amount}}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
              <div v-else class="fontColor">暂无</div>
            </el-form>
            <div class="line" />
            <h5 class="titleInfo">团队奖励</h5>
            <el-form ref="form1" :inline="true" :model="form1" label-width="150px">
              <div v-if="form1.list2.length>0">
                <el-row v-for="(item,index) in form1.list2" :key="index">
                  <el-col :span="12">
                    <el-form-item label="奖励人员">
                      <span class="spanToInput">{{item.realName}}{{item.username}}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="人员级别">
                      <span class="spanToInput">{{item.roleName}}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="奖励比例(%)">
                      <span class="spanToInput">{{item.rewardRate | nullFn}}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="奖励金额">
                      <span class="spanToInput">{{item.amount}}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
              <div v-else class="fontColor">暂无</div>
            </el-form>
            <div class="line" />
            <h5 class="titleInfo">区域奖励</h5>
            <el-form ref="form1" :inline="true" :model="form1" label-width="150px">
              <div v-if="form1.list3.length>0">
                <el-row v-for="(item,index) in form1.list3" :key="index">
                  <el-col :span="12">
                    <el-form-item label="奖励人员">
                      <span class="spanToInput">{{item.realName}}{{item.username}}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="人员级别">
                      <span class="spanToInput">{{item.roleName}}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="奖励比例(%)">
                      <span class="spanToInput">{{item.rewardRate | nullFn}}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="奖励金额">
                      <span class="spanToInput">{{item.amount}}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
              <div v-else class="fontColor">暂无</div>
            </el-form>
          </el-col>
          <el-col :span="8">
            <div class="recommend">
              <div>当前推荐关系</div>
              <div v-if="userList.length>0">
                <div class="box" v-for="(item,index) in userList" :key="index">
                  <div class="boxContent">{{item}}</div>
                  <div class="arrow" v-if="index!=userList.length-1">↓</div>
                </div>
              </div>
              <div v-else class="mb_20">暂无</div>
            </div>
          </el-col>
        </el-row>
      </div>
    </el-dialog>-->
    <!-- 分成详情弹窗 -->
    <el-dialog title="分成详情" :visible.sync="dividedDialogVisible" width="80%" center>
      <!-- <div class="content"> -->
      <h5 class="titleInfo">分成详情</h5>
      <el-row>
        <el-col :span="16" style="background:white">
          <el-form
            ref="form1"
            :inline="true"
            label-position="top"
            :model="form1"
            label-width="200px"
          >
            <el-row>
              <el-col :span="8">
                <el-form-item label="订单编号">
                  <span class="spanToInput">{{form1.detailInfo.order_sn | noFn}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="购买人姓名">
                  <span class="spanToInput">
                    <span
                      v-if="form1.detailInfo.buy_user"
                    >{{form1.detailInfo.buy_user.realname | noFn}}</span>
                  </span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="手机号">
                  <span class="spanToInput">
                    <span
                      v-if="form1.detailInfo.buy_user"
                    >{{form1.detailInfo.buy_user.referee | noFn}}</span>
                  </span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="购买数量">
                  <span class="spanToInput">{{form1.detailInfo.number | noFn}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="实付金额">
                  <span class="spanToInput">{{form1.detailInfo.order_price | noFn}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="订单生成时间">
                  <span class="spanToInput">{{(form1.detailInfo.created_at-0)*1000|date(1)}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="分成发放时间">
                  <span class="spanToInput">{{form1.applyTime | noFn}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="订单状态">
                  <span class="spanToInput">{{form1.detailInfo.order_status | statusFn}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="分成模式">
                  <span class="spanToInput">{{form1.formTypeValue | noFn}}</span>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <div v-loading="tableLoading1" style="width:100%;">
                  <el-table ref="tableData1" :data="tableData1" border>
                    <el-table-column label="推荐人姓名" prop="realName" align="center" />
                    <el-table-column label="手机号" prop="username" align="center" />
                    <el-table-column label="推荐人级别" prop="roleName" align="center" />
                    <el-table-column label="奖励金额" prop="amount" align="center" />
                    <el-table-column label="奖励比率(%)" prop="rewardRate" align="center" />
                    <el-table-column label="奖励类型" prop="awardType" align="center">
                      <template slot-scope="scope">{{scope.row.awardType|awardTypeFilter}}</template>
                    </el-table-column>
                    <el-table-column label="分成基数" prop="moneyBase" align="center" />
                    <el-table-column label="分成基数类型" prop="moneyBaseTypeValue" align="center" />
                    <el-table-column label="金币分成冻结" prop="goldAwardFreezeValue" align="center" />
                    <el-table-column label="创建时间" prop="createDate" align="center" />
                  </el-table>
                </div>
              </el-col>
            </el-row>
          </el-form>
        </el-col>
        <!-- </el-row>
        <el-row>-->

        <el-col :span="8">
          <div class="recommend">
            <div>当前推荐关系</div>
            <div v-if="userList.length>0">
              <div class="box" v-for="(item,index) in userList" :key="index">
                <div class="boxContent">{{item}}</div>
                <div class="arrow" v-if="index!=userList.length-1">↓</div>
              </div>
            </div>
            <div v-else class="mb_20">暂无</div>
          </div>
        </el-col>
      </el-row>
      <!-- </div> -->
    </el-dialog>
  </div>
</template>

<script>
import axios from "axios";
import serv from "@/utils/request1";

import {
  card_ticket_index,
  refund,
  refund_cancle,
  getApplyDetailByCardOrderId,
} from "@/api/PlatformCardOrder";
import commonFn from "@/utils/common";
import filter from "@/assets/filter";
export default {
  name: "PlatformCardOrder",
  data() {
    return {
      http: serv.baseURLApp,
      created_at: [],
      pay_time: [],
      form: {
        type: 1,
        id: "",
        order_sn: "",
        username: "",
        referee: "",
        order_status: "",
        created_at: "",
        pay_time: "",
        page: 1,
        pagesize: 10,
      },
      form1: {
        list1: [],
        list2: [],
        list3: [],
        listDetail: {},
        detailInfo: {},
        formTypeValue: "",
        applyTime: "",
      },
      userList: [],
      dividedInfo: [],
      type: "",
      placeDates: null,
      payDates: null,
      // 分页
      page_sizes: [10, 30, 50, 100], // 每页显示个数
      page_totals: 0, // 总条目数,
      statusType: [
        // 1：待支付 2：定金支付（待尾款支付） 3. 已完成  4：待退款 5：已退款  6:已取消  （含订单已超时取消）
        //'订单状态 1：待支付 2：待发货 3：待收货 4：待评价 5：已完成 6：待退款 7：已退款  8:已取消 9：客服介入 10：待尾款支付 11:尾款待支付 12：订单已超时',
        { name: "待支付", value: 1 },
        // { name: "待发货", value: 2 },
        // { name: "待收货", value: 3 },
        // { name: "待评价", value: 4 },
        { name: "已完成", value: 5 },
        { name: "待退款", value: 6 },
        { name: "已退款", value: 7 },
        { name: "已取消", value: 8 },
        // { name: "客服介入", value: 9 },
        { name: "待尾款支付", value: 10 },
        // { name: "尾款待支付", value: 11 },
        // { name: "订单已超时", value: 12 },
        // { name: "退款异常", value: 13 },
        // { name: "支付异常", value: 14 }
      ],
      tableData: [],
      tableData1: [], //分成详情
      tableLoading: true,
      infoLoading: true,
      tableLoading1: true,
      dividedDialogVisible: false, //分成
      dialogFormVisible: false, //女王卡优化分成
    };
  },
  filters: {
    // 奖励类型 0 无 1 一级服务商奖励2 二级服务商奖励 3 团队奖励 4区域省奖励(老) 5区域市奖励(老) 6特殊奖励
    // 7省奖励（新）8大区域奖励 9业绩二单奖励 10团队二单奖励 11业绩奖励（系统加减） 12团队奖励（系统加减）
    // 13试用业绩奖励 14试用团队奖励 15试用大区域奖励 16会员（拼团）17序列码奖励"
    awardTypeFilter(e) {
      switch (e) {
        case 1:
          return "一级服务商奖励";
          break;
        case 2:
          return "二级服务商奖励";
          break;
        case 3:
          return "团队奖励";
          break;
        case 4:
          return "区域省奖励(老)";
          break;
        case 5:
          return "区域市奖励(老)";
          break;
        case 6:
          return "特殊奖励";
          break;
        case 7:
          return "省奖励（新）";
          break;
        case 8:
          return "大区域奖励";
          break;
        case 9:
          return "业绩二单奖励";
          break;
        case 10:
          return "团队二单奖励";
          break;
        case 11:
          return "业绩奖励（系统加减）";
          break;
        case 12:
          return "团队奖励（系统加减）";
          break;
        case 13:
          return "试用业绩奖励";
          break;
        case 14:
          return "试用团队奖励";
          break;
        case 15:
          return "试用大区域奖励";
          break;
        case 16:
          return "会员（拼团）";
          break;
        case 17:
          return "序列码奖励";
          break;
        default:
          return "无";
          break;
      }
    },
    // 订单状态
    statusFn(opt) {
      switch (opt) {
        case 1:
          return "待支付";
          break;
        // case 2:
        //   return "待发货";
        //   break;
        // case 3:
        //   return "待收货";
        //   break;
        // case 4:
        //   return "待评价";
        //   break;
        case 5:
          return "已完成";
          break;
        case 6:
          return "待退款";
          break;
        case 7:
          return "已退款";
          break;
        case 8:
          return "已取消";
          break;
        // case 9:
        //   return "客服介入";
        //   break;
        case 10:
          return "待尾款支付";
          break;
        // case 11:
        //   return "尾款待支付";
        //   break;
        // case 12:
        //   return "订单已超时";
        //   break;
        // case 13:
        //   return "退款异常";
        //   break;
        // case 14:
        //   return "支付异常";
        //   break;
        default:
          // return "暂无";
          break;
      }
    },
    nullFn(opt) {
      if (opt) {
        return opt;
      } else {
        return "--";
      }
    },
    // 无数据显示
    noFn(opt) {
      if (opt) {
        return opt;
      } else {
        return "";
      }
    },
  },
  watch: {
    // params(val){
    //   console.log(val)
    //   this.$emit("childfun", this.params);
    // }
    created_at(val) {
      this.form.created_at = this.created_at
        ? this.created_at[0] + " - " + this.created_at[1]
        : "";
    },
    pay_time(val) {
      this.form.pay_time = this.pay_time
        ? this.pay_time[0] + " - " + this.pay_time[1]
        : "";
    },
  },
  created() {
    this.getList(this.form);
    console.log(121, process.env.BASE_API2);
  },
  methods: {
    toRoutes(name) {
      let route = { name };
      this.$router.push(route);
    },
    // 序号
    table_index(index) {
      return (this.form.page - 1) * this.form.pagesize + index + 1;
    },
    // 获取列表
    getList(e) {
      card_ticket_index(e)
        .then((res) => {
          console.log("xinagqing", res);
          if (res.data.code == 200) {
            this.tableData = res.data.data.data;
            this.page_totals = res.data.data.total;
          } else {
            this.$message({
              showClose: true,
              message: res.data.msg,
              type: "warning",
            });
          }
          this.tableLoading = false;
        })
        .catch((err) => {
          this.errorStatus(err.msg);
          this.tableLoading = false;
        });
    },
    // 退款
    paymentCom(id, reason, realname, phone, goods_name) {
      console.log(reason);
      let datas = {
        order_id: id,
        operate_reason: reason ? reason.operate_reason : "",
        operate_name: localStorage.getItem("username"),
      };
      this.$confirm(
        "确认" +
          realname +
          "用户" +
          phone +
          "手机号的" +
          goods_name +
          "进行退款",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          //https://mp.yuepinyuemei.com/api
          axios
            .post(
              process.env.BASE_API2 + "/v4_5/market_order/refund",
              // "https://mp.yuepinyuemei.com/api/v4_5/market_order/refund",
              datas
            )
            .then((res) => {
              console.log("退款", res);
              if (res.data.status_code == "0") {
                this.$message({
                  type: "success",
                  message: "退款成功!",
                });
                this.getList(this.form);
              } else {
                this.$message({
                  type: "info",
                  message: res.data.message,
                });
              }
            });
        })

        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });

      // .then(() => {
      //   refund(datas).then(res => {
      //     if (res.data.code == 200) {
      //       this.getList(this.form);
      //     } else {
      //       this.$message({
      //         type: "info",
      //         message: res.data.msg
      //       });
      //     }
      //   });
      // })
      // .catch(() => {
      //   this.$message({
      //     type: "info",
      //     message: "已取消"
      //   });
      // });
    },
    //拒绝退款
    RefuseRefund(id, reason, realname, phone, goods_name) {
      let datas = {
        id: id,
        operate_name: localStorage.getItem("username"),
      };
      this.$confirm(
        "确认拒绝" +
          realname +
          "用户" +
          phone +
          "手机号的" +
          goods_name +
          "退款",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          refund_cancle(datas).then((res) => {
            if (res.data.code == 200) {
              this.getList(this.form);
            } else {
              this.$message({
                type: "info",
                message: res.data.msg,
              });
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    // 分成详情
    getDetail(id) {
      this.infoLoading = true;
      let data = { id: id };
      getApplyDetailByCardOrderId(data)
        .then((res) => {
          console.log("分成详情", res);
          if (res.data.code == 0 && res.data.data) {
            this.infoLoading = false;
            this.tableLoading1 = false;
            // this.form1.listDetail = res.data.data;
            this.form1.formTypeValue = res.data.data.formTypeValue;
            this.form1.applyTime = res.data.data.applyTime;
            //奖励
            // let arr = [];
            // let arr1 = [];
            // let arr2 = [];
            // if (res.data.data) {
            //   res.data.data.rewardList.forEach(item => {
            //     if (
            //       item.awardType == 16 ||
            //       item.awardType == 1 ||
            //       item.awardType == 2
            //     ) {
            //       arr.push(item);
            //     }
            //     if (item.awardType == 3) {
            //       arr1.push(item);
            //     }
            //     if (item.awardType == 8) {
            //       arr2.push(item);
            //     }
            //     this.form1.list1 = arr;
            //     this.form1.list2 = arr1;
            //     this.form1.list3 = arr2;
            //   });
            // } else {
            //   this.form1.list1 = [];
            //   this.form1.list2 = [];
            //   this.form1.list3 = [];
            // }
            this.tableData1 = res.data.data.rewardList;
            //分成用户链条
            this.userList = res.data.data.userList;
          } else {
            this.$message({
              showClose: true,
              message: res.data.msg,
              type: "warning",
            });
          }
        })
        .catch((err) => {
          this.errorStatus("补贴单未复审!");
        });
    },
    // 分成详情
    dividedEtails(id, info) {
      console.log("info", info);
      this.form1.detailInfo = info;
      this.form1.detailInfo.number = 1; //暂时固定数量为1
      let data = {
        orderId: id,
        type: 8,
      };
      this.getDetail(id);
      // this.getUser(data);
      // this.detailInto(data);
      this.dividedDialogVisible = true;
    },

    // 分成弹窗关闭事件
    close() {
      this.dividedDialogVisible = false;
      this.form1 = {
        list1: [],
        list2: [],
        list3: [],
        listDetail: {},
        detailInfo: {},
      };
      this.userList = [];
    },
    // 查询
    handleSearch() {
      this.form.page = 1;
      this.getList(this.form);
    },

    // 导出
    handleExport() {
      let datas = { ...this.form };
      delete datas.page;
      delete datas.pagesize;
      orderExport(datas)
        .then((res) => {
          commonFn.downFile("卡订单导出", res);
        })
        .catch((err) => {
          this.errorStatus(err.msg);
        });
    },
    // 改变页面条数
    handleSizeChange(val) {
      this.form.pagesize = val;
      this.getList(this.form);
    },
    // 选择页数
    handleCurrentChange(val) {
      this.form.page = val;
      this.getList(this.form);
    },
    // // 弹窗组件
    eleMsg(txt, status) {
      this.$message({
        showClose: true,
        message: txt,
        type: status,
      });
    },
    // 失败状态弹窗
    errorStatus(txt) {
      this.eleMsg(txt, "error");
    },
  },
};
</script>
<style scoped>
.app-container {
  padding: 0px !important;
  background: transparent;
}
.el-range-editor--medium.el-input__inner {
  width: 236px;
}
.pagesCon {
  text-align: right;
  margin-top: 20px;
}
.allCenter {
  text-align: center;
}
.spanToInput {
  width: 205px;
  min-height: 30px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  border: 1px solid #ddd;
  text-align: left;
  padding: 0 12px;
}
.line {
  height: 25px;
  background: #f7f7f7;
}
.recommend {
  min-width: 280px;
  color: #1d2023;
  text-align: center;
  font-size: 16px;
  margin-left: 25px;
}
.boxContent {
  margin-top: 20px;
  height: 25px;
  line-height: 25px;
  border: 1px solid #ddd;
  text-align: center;
  padding: 0 12px;
}
.arrow {
  text-align: center;
  padding: 12px 0 0 0;
}
.fontColor {
  font-size: 16px;
  text-align: center;
  margin-bottom: 15px;
}
.mb_20 {
  font-size: 20px;
  text-align: center;
  margin-top: 20px;
}
</style>